package com.icss.train_sys_back.enumEntity;

import lombok.Getter;

/**
 * 座位类型票价调整系数枚举类
 */
@Getter
public enum SeatTypePriceAdjustment {
    /**
     * 一等座：基础票价 + 100元
     */
    FIRST_CLASS(1, 100),
    /**
     * 二等座：基础票价 + 0元
     */
    SECOND_CLASS(2, 0),
    /**
     * 商务座：基础票价 + 200元
     */
    BUSINESS_CLASS(3, 200),
    /**
     * 硬座：基础票价 - 50元
     */
    HARD_SEAT(4, -50),
    /**
     * 硬卧：基础票价 + 50元
     */
    HARD_SLEEPER(5, 50),
    /**
     * 软卧：基础票价 + 100元
     */
    SOFT_SLEEPER(6, 100);

    private final int code;
    private final int adjustmentAmount;

    SeatTypePriceAdjustment(int code, int adjustmentAmount) {
        this.code = code;
        this.adjustmentAmount = adjustmentAmount;
    }

    /**
     * 根据编码获取座位类型枚举
     * @param code 座位类型编码
     * @return 对应的座位类型枚举
     */
    public static SeatTypePriceAdjustment getByCode(int code) {
        for (SeatTypePriceAdjustment type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效的座位类型编码: " + code);
    }

}
